package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Subject;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SubjectDAO{
	
	@SQL("SELECT * FROM Subject WHERE deleteFlag=1 #if(:t.name!=''){AND name like '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Subject> query(@SQLParam("t") Subject subject);
	
	@SQL("SELECT count(*) FROM Subject WHERE deleteFlag=1 #if(:t.name!=''){AND name like '%##(:t.name)%' } ")
	int querySize(@SQLParam("t") Subject subject);
    
    @SQL("select * from Subject where id=:1")
    Subject queryById(int id);
    
    @SQL("INSERT INTO Subject (columnsId,name,carouselImage,descs,status,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.columnsId,:t.name,:t.carouselImage,:t.descs,:t.status,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") Subject subject);
	
	@SQL("UPDATE Subject SET columnsId=:t.columnsId,name=:t.name,carouselImage=:t.carouselImage,descs=:t.descs,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id")
    void update(@SQLParam("t") Subject subject);
    
    @SQL("UPDATE Subject SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    @SQL("UPDATE Subject SET status=0,updateAT=now() WHERE id=:1")
    void updateByStatusFb(int id);
	
	@SQL("UPDATE Subject SET status=1,updateAT=now() WHERE id=:1")
    void updateByStatusWfb(int id);

	@SQL("select id,columnsId,name from Subject where deleteFlag=1 AND columnsId in (:1) ")
	List<Subject> queryByColIds(List<Integer> colIds);
}